﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace KnowlegeAssistant
{
    public partial class SelectGroupStudentForStatisticsForm : Form
    {
        public enum LoadType{student, group}

        private LoadType loadtype;
        int user_id = 0;
        int group_id = 0;

        public SelectGroupStudentForStatisticsForm(LoadType loadtype)
        {
            InitializeComponent();
            this.loadtype = loadtype;
            if (this.loadtype == LoadType.group)
            {
                label1.Text = "Выберете группу";
                comboBox1.DataSource = GroupUtil.GetAllGroups();
                comboBox1.DisplayMember = "GroupName";
            }
            else
            {
                comboBox1.DataSource = StudentUtil.GetListStudentForStatistics();
                comboBox1.DisplayMember = "FullName";
            }
        }

        private void SelectGroupStudentForStatisticsForm_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox1.SelectedItem != null)
            {
                if (loadtype == LoadType.group)
                {
                    this.group_id = ((Group)comboBox1.SelectedItem).GroupID;
                }
                else { this.user_id = ((Student)comboBox1.SelectedItem).UserID; }
            }
            this.Close();
        }

        public int GroupID
        {
            get { return this.group_id; }
        }
        public int UserID
        {
            get { return this.user_id; }
        }
    }
}
